home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / mouse01g.zip / MOUSTEST.C < prev    next >
C/C++ Source or Header  |  1992-05-24  |  827b  |  29 lines

  1. /* Sample main that uses cursor keys. Interface to mouse on lines 4,8,26. */
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include "mouse1g.c"
  5.  
  6. main(){
  7. int row,col,x;
  8.  mousereset(); mousehook();             /* Turn on mouse */
  9.  clrscr(); row=1; col=1; gotoxy(col,row); putch('*'); gotoxy(col,row);
  10.  while(1){
  11.    x=getch();
  12.    if(x==3 || x==27) break;
  13.    if(x==0){
  14.      x=getch();
  15.      switch(x){
  16.        case 'H': /* Up    */ --row; break;
  17.        case 'P': /* Down  */ ++row; break;
  18.        case 'K': /* Left  */ --col; break;
  19.        case 'M': /* Right */ ++col; break;
  20.      }
  21.      if(row < 1) row=1; if(row > 24) row=25;
  22.      if(col<1) col=1; if(col>78) col=79;
  23.      putch(' '); gotoxy(col,row); putch('*'); gotoxy(col,row);
  24.    }
  25.  }
  26.  mousereset();                          /* Turn off mouse */
  27.  clrscr();
  28. }
  29.